﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Mobile.Models.ProductListModels>" %>
<%@ Import Namespace = "SDT.Lib.Paging" %>
<%@ Import Namespace = "SDT.Lib.Helpers" %>
<%@ Import Namespace = "SDT.Model" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	timkiem
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"><div id="top"></div>
<div class="mar_top">
   <form action="/Product/Index/" method="post">
       <input type="text" name="productname" />
        <%=Html.DropDownList("ddlProductType", new SelectList(Model.ProductTypes, "ID", "Name"), "-- Chọn Danh mục -- ", new { })%>
       <label>&nbsp;</label><input type="submit" value="" class="btn" />
   </form>
 </div>
<div class="tit_bg"><span class="pad"></span> &nbsp;</div>
<br />
 <% if (Model.ProductPaging.Count == 0)
    { %>
 <div class="tit_new">Không tìm thấy sản phẩm nào</div>
 <% }
    else
    { %><div class="kqsr_titsr">
        	<ul>
            <% List<ProductCategory> list1 = ViewData["productcategory"] as List<ProductCategory>;
                 if (list1 != null)
                     {
                         foreach (var item in list1)
                             { %>
                                <li>Loại BĐS : <strong> <%= item.Name%></strong></li>
                             <%  }
                     } %>
            <% List<City> list2 = ViewData["city"] as List<City>;
                if (list2 != null)
                    {
                       foreach (var item in list2)
                         { %>
                            <li>Tỉnh/Thành phố : <strong> <%= item.Name%></strong></li>
                         <%  }
                     } %>
             <% List<District> list3 = ViewData["district"] as List<District>;
                 if (list3 != null)
                 {
                  foreach (var item in list3)
                  { %>
                 <li>Quận/Huyện : <strong> <%= item.Name%></strong></li>
               <%  }
          } %>
	</ul>
   </div>
   <div class="clear"></div>
   <div><p>Có tổng số : <strong> <%= Model.ProductPaging.Count%>  </strong>  Kết quả</p></div>
    <%foreach (var item in Model.ProductPaging)
         { %>
        <div class="tit_new"><a href="/Product/Detail/<%= item.ID %>" class="l_red"><%= item.Title%> </a></div>
        <p><%=item.AddDate %></p>
        <p><%= item.Summary%>....</p>
        <%} %>
 	    <div class="bg_paging">
        	<div class="pages">
                <span><%= Html.Pager(Model.ProductPaging.PageSize, Model.ProductPaging.PageNumber, Model.ProductPaging.TotalItemCount)%></span>
            </div>
            <br style="clear:both" />
        </div>
        <% } %>
        <div class="clear"></div>
  <div class="line_dot"></div>
  <div class="sr_list">
  <form action="/Product/timkiem/">
     <table>
        <tr>
           <td><strong>Loại Tin</strong>&nbsp;</td>
           <td><%=Html.DropDownList("ddProductType", new SelectList(Model.ProductTypes, "ID", "Name", ViewData["loaitin"]), "-- Chọn Danh mục -- ", new { style = "width:150px" })%></td>
        </tr>
        <tr>
          <td><strong>Loại Nhà Đất</strong>&nbsp;</td>
          <td><select id="ddlCat" name="ddlCat" style="width:150px" >
                 <option>--Chọn Loại Nhà Đất --</option>
               </select>
           </td>
         </tr>
         <tr>
             <td><strong>Tỉnh/Thành phố</strong> &nbsp;</td>
             <td><%=Html.DropDownList("ddlCity", new SelectList(Model.Cities, "ID", "Name", ViewData["city"]), "-- Tỉnh/Thành Phố -- ", new { style = "width:150px" })%></td>
         </tr>
         <tr>
            <td><strong>Quận/Huyện</strong> &nbsp; </td>
            <td><select id="ddlDistrict" name="ddlDistrict" style="width:150px">
                   <option>--Chọn Quận/ Huyện --</option>
                </select>
            </td>
        </tr>
        <tr>
            <td><strong>Diện Tích</strong>&nbsp;</td>
             <td><select id="ddlArea" name="ddlArea" style="width:150px">
                    <option>--Chọn Diện Tích --</option>
                 </select>
              </td>
         </tr>
         <tr>
             <td><strong>Giá</strong>&nbsp;</td>
             <td><select id="ddlPrice" name="ddlPrice" style="width:150px" >
                    <option>--Chọn Mức Giá --</option>
                  </select>
             </td>
          </tr>
          <tr>
              <td><strong>Dự án</strong>&nbsp;</td>
              <td><select id="ddlProject" name="ddlProject" style="width:150px" >
                        <option>--Chọn Dự Án --</option>
                  </select>
              </td>
           </tr>
           <tr>
                <td><label>&nbsp;</label></td>
                <td> <label>&nbsp;</label><input type="submit" value="" class="btn" /></td>
           </tr>
        </table>
      </form>
     </div>    
   <div class="clear"></div>
  <div class="line_dot"></div>
        <br />
        <div class="t_sm">site map</div>
        <div><a href="/Home/index" class="l_blue">Trang chủ</a></div>
        <div class="list_st">
            <ul>
            <% foreach (var item1 in Model.ProductTypes)
               { %>
                    <li><a href="/Product/Index/<%= item1.ID %>" > <%= item1.Name%></a></li>
              <% } %>
               <% foreach (var item2 in Model.ArticleCategorys)
                  { %>
                    <li><a href="/Article/Index/<%= item2.ID %>" ><%= item2.Name%></a></li>
              <% } %>
            </ul>
        </div>
     <div class="f_r"><a href="#top" class="l_gr">Lên đầu trang</a></div>
     <div class="clear"></div>  
<script type="text/javascript">
    $(document).ready(function() {

    var id = $('#ddProductType').val() == "" ? 0 : $('#ddProductType').val();
    /* lay loai bat dong san */
            $.get('/AjaxData/GetProductCategoryByType/' + id, function(data) {
            $('#ddlCat').html(data);
                 var a = <%=ViewData["cat"] %>;
                 $("#ddlCat option[value='" + a +"']").attr("selected","selected");
                 });
        /* lay gia */            
            $.get('/AjaxData/GetPrice/' + id, function(data) {
                $('#ddlPrice').html(data);
                 var c = <%=ViewData["price"] %>;
                $("#ddlPrice option[value='" + c +"']").attr("selected","selected");
                  });
              /* lay dien tich */       
            $.get('/AjaxData/GetArea/' + id, function(data) {
            $('#ddlArea').html(data);    
            var d = <%=ViewData["area"] %>;
                $("#ddlArea option[value='" + d +"']").attr("selected","selected");
                  });
              /*lay quan huyen*/    
             var id2 = $('#ddlCity').val() == "" ? 0 : $('#ddlCity').val();
             $.get('/AjaxData/GetDistrict/' + id2, function(data) {
                $('#ddlDistrict').html(data);
                 var f = <%=ViewData["district"] %>;
                $("#ddlDistrict option[value='" + f +"']").attr("selected","selected");
                /*lay project*/   
                var id = $('#ddlDistrict').val() == "" ? 0 : $('#ddlDistrict').val();
                $.get('/AjaxData/GetProjectByDistrict/' + id, function(data) {
                 $('#ddlProject').html(data);
                 var e = <%=ViewData["project"] %>;
                $("#ddlProject option[value='" + e +"']").attr("selected","selected");  
               });
                });
            
      $('#ddProductType').change(function() {
      var id = $('#ddProductType').val() == "" ? 0 : $('#ddProductType').val();
            $.get('/AjaxData/GetProductCategoryByType/' + id, function(data) {
                $('#ddlCat').html(data);
            });
        });
       
        $('#ddlCity').change(function() {
            var id = $('#ddlCity').val() == "" ? 0 : $('#ddlCity').val();
             $.get('/AjaxData/GetDistrict/' + id, function(data) {
                $('#ddlDistrict').html(data);
            });
        });
        $('#ddProductType').change(function() {
            var id = $('#ddProductType').val() == "" ? 0 : $('#ddProductType').val();
            $.get('/AjaxData/GetPrice/' + id, function(data) {
            $('#ddlPrice').html(data);
            });
        });
        $('#ddProductType').change(function() {
            var id = $('#ddProductType').val() == "" ? 0 : $('#ddProductType').val();
            $.get('/AjaxData/GetArea/' + id, function(data) {
            $('#ddlArea').html(data);
            });
        });
        $('#ddlDistrict').change(function() {
        var id = $('#ddlDistrict').val() == "" ? 0 : $('#ddlDistrict').val();
        $.get('/AjaxData/GetProjectByDistrict/' + id, function(data) {
            $('#ddlProject').html(data);
            });
        });
    });
</script>
</asp:Content>
